<?php
$jobslist = $_['jobslist'];
$pagination = $_['pagination'];
$app = PFactory::getApplication();
$limit = $app->getUserStateFromRequest('companyjoblist.limit', 'limit', 20, 'int');
$user=PFactory::getMasterUser();
$jobsaved=OC_Preferences::getValue(OC_User::getUser(), 'company', 'show_jobsaved');
?>
<script language="javascript" type="text/javascript">
   jQuery(document).ready(function($) {
      <?php if($pagination->pagesTotal > 1): ?>
         $("#joblist .list-footer:first").pager({ 
            pageCount: <?php echo $pagination->pagesTotal; ?>,
            currentPage: <?php echo ($pagination->pagesCurrent -1); ?>
         }).delegate("li.active", "click", function(e) {
            var page = parseInt($(this).attr('page'));
            var url = getUrlQuery(OC.filePath('jobposition', 'ajax', 'getjoblist.php'), "start=" + (page * <?=$limit?>)); 
            var target = $(this);
            $.ajax({
               url: url,
               beforeSend: function(xhr, settings) {
                  showLoading(target, settings, null, {button:true});
               },
               success: function(data) {
                  jQuery("#joblist").fadeOut("fast", function() { 
                     jQuery("#joblist").html(data).fadeIn(); 
                  }); 
               }
            })
         }).parent().show();
      <?php endif; ?> 
   })
</script>

<table width="100%" border="0" cellpadding="0" cellspacing="0">
   <tr>
      <th style="padding-left:20px;">职位<input id="collection" name="collection" type="checkbox" style="margin-top:0px;" <?php echo !empty($jobsaved) ? 'checked':'';?>/><a class="select_saveposition">查看收藏职位</a></th>
      <th>总简历数</th>
      <th>昨天新增</th>
      <th>匹配条件</th>
   </tr>
<?php if(empty($jobslist)){ ?>
         <tr>
            <td class="nodatatd yahei" colspan="4" style="padding-left:20px;">
              <?php if (PCompanyHelper::checkCRUDPermission()) { ?>
                 <?php echo !empty($jobsaved) ? '您暂无收藏职位，取消勾选可查看全部职位':'暂无信息，请您先 <a href="'.OC_Helper::linkToRoute("company_synchronousinfo").'">同步职位</a> 或 <a href="'.OC_Helper::linkToRoute("jobpos_postjob").'">发布职位</a>';?> 
              <?php } else { ?>
                 <?php echo "您暂无职位";?>
              <?php } ?>
            </td>
         </tr>
<?php }else{
   $num = 0;
   foreach ($jobslist as $joblist) {
?>
   	<tr <?=($num%2 == 0) ? 'bgcolor="#fbfcfd"' : ''?>>
         <td style="padding-left:20px; font-size:14px;">
            <a href="<?=OC_Helper::linkToRoute("jobpos_setup", array('id'=>$joblist['job_id'], 'job_title'=>$joblist['job_title']))?>#interview"><?=strmaxwordlen($joblist['job_title'], 16)?></a>
         </td>
         <td width="110">
            <?php if($joblist['totalresumesnum'] > 0): ?>
               <a href="<?=OC_Helper::linkToRoute("resumes_jobpos", array('jobid'=>$joblist['job_id']))?>"><?=$joblist['totalresumesnum']?></a>
            <?php else: ?>
               <?=$joblist['totalresumesnum']?>
            <?php endif; ?>
         </td>
         <td width="90">
            <?=$joblist['yesterdayresumesnum']?>
         </td>
         <td width="90">
            <?php if(!$joblist['has_interview'] && PCompanyHelper::checkJobManagerPermissions($joblist['job_id'])){ ?>
            <a href="<?php echo OC_Helper::linkToRoute("jobpos_setup", array('id'=>$joblist['job_id'], 'job_title'=>$joblist['job_title'])); ?>#interview" style="color:#d2871d;">立即设置</a>
            <?php } ?>
         </td>
      </tr>
   <?php
      $num++;
   }}
   ?>
   <tr>
      <td colspan="5" class="row3" style="display: <?php echo ($pagination->pagesTotal > 1) ? '' : 'none'?>">
      <?php
         echo '<div class="list-footer"></div>'; 
      ?>
      </td>
   </tr>
</table>
